
import java.util.concurrent.ThreadFactory;
import java.util.concurrent.atomic.AtomicInteger;

/**
 * Created with Intel IDEA.
 * 通用的线程池工厂
 *
 * @Auther: gjt
 * @Date: 2024/3/20 16:12
 */


public class ThreadPoolFactory implements ThreadFactory {
    private AtomicInteger threadIndex = new AtomicInteger(0);
    private String threadName;

    public ThreadPoolFactory(String threadName) {
        this.threadName = threadName;
    }

    @Override
    public Thread newThread(Runnable r) {
        Thread thread = new Thread(r);
        thread.setName(threadName + "-xxxjob" + threadIndex.getAndIncrement());
        return thread;
    }
}


